package com.dwy2002.room;

import com.dwy2002.common.Result;
import com.dwy2002.common.annotation.RequiresPermission;
import com.dwy2002.enums.Logical;
import com.dwy2002.pojo.dto.rooms.UnavailableDateDTO;
import com.dwy2002.room.service.IUnavailableDateService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author 杜伟毅
 * @version 1.0
 * @since 2025/05/07
 */
@RestController
@RequestMapping("/rooms/unavailableDate")
@RequiredArgsConstructor
public class UnavailableDateController {
    private final IUnavailableDateService service;

    /**
     * 设置不可预约的时间
     *
     * @param dto 接收前端的不可预约日期
     * @author 杜伟毅
     * @since 2025/5/8 0008 0:01
     */
    @RequiresPermission(value = {"A8"}, logical = Logical.OR)
    @PostMapping
    public Result<Void> saveUnavailableDate(@RequestBody UnavailableDateDTO dto) {
        return service.saveUnavailableDate(dto);
    }

    /**
     * 删除预约时间
     *
     * @param id 时间id
     * @return true:删除成功，false：删除失败
     * @author 杜伟毅
     * @since 2025/5/8 0008 12:49
     */
    @RequiresPermission(value = {"A8"}, logical = Logical.OR)
    @DeleteMapping("/{id}")
    public Result<Void> removeUnavailableDate(@PathVariable String id) {
        return service.removeUnavailableDate(id);
    }
}
